package processing.core;

import com.google.gwt.core.client.JavaScriptObject;




public  class PApplet   
{
	
	
		public  PApplet (JavaScriptObject object)
		{
			init(object);
		}
		
		private native void init(JavaScriptObject object)/*-{
		
			this.@processing.core.PApplet::height = object.height;
			this.@processing.core.PApplet::width  = object.width;
			this.@processing.core.PApplet::gl = object;
			
		}-*/;
		
		private JavaScriptObject gl;
		
		
	  /**
	   * PI is a mathematical constant with the value 3.14159265358979323846.
	   * It is the ratio of the circumference of a circle to its diameter.
	   * It is useful in combination with the trigonometric functions <b>sin()</b> and <b>cos()</b>.
	   * 
	   * @webref constants
	   * @see processing.core.PConstants#HALF_PI
	   * @see processing.core.PConstants#TWO_PI
	   * @see processing.core.PConstants#QUARTER_PI
	   * 
	   */
	  static final float PI = (float) Math.PI;
	  static final float DEG_TO_RAD = PI/180.0f;	  
	  static final float RAD_TO_DEG = 180.0f/PI;
	
  /** height of this applet's associated PGraphics
   * @webref environment
   * */	
	public   float height;
	
  /** width of this applet's associated PGraphics
   * @webref environment
   */	
	public   float width;
	

	
//	public  final native void test(float param1)/*-{
//							
//		this.rotateY(param1);
//		
//	}-*/;	

	
	public static final native void log(String message)/*-{
	
		alert(message);
	
	}-*/;	

	  
	public  final native void perspective(float theFoV, float theAspect, float theNearClip,
			float theFarClip)/*-{
				
				var gl = this.@processing.core.PApplet::gl;
				gl.perspective(theFoV,  theAspect, theNearClip,theFarClip);				
	}-*/;
	public  final native void camera(float theCameraX, float theCameraY, float theCameraZ,
			float theTargetX, float theTargetY, float theTargetZ, float theUpX,
			float theUpY, float theUpZ)/*-{
			
			
				var gl = this.@processing.core.PApplet::gl;
				
				gl.camera(theCameraX, theCameraY, theCameraZ,
				theTargetX, theTargetY, theTargetZ, theUpX,
				theUpY, theUpZ);
	}-*/;
	
	  static public final float sin(float angle) {
		    return (float)Math.sin(angle);
		  }
	
		  static public final float cos(float angle) {
		    return (float)Math.cos(angle);
		  }
	
		  static public final float tan(float angle) {
		    return (float)Math.tan(angle);
		  }
	
		  static public final float sqrt(float a) {
			    return (float)Math.sqrt(a);
		  }
		  		  
	  static public final float atan2(float a, float b) {
		    return (float)Math.atan2(a, b);
		  }
	  static public final float degrees(float radians) {
		    return radians * RAD_TO_DEG;
		  }
	  static public final float constrain(float amt, float low, float high) {
		    return (amt < low) ? low : ((amt > high) ? high : amt);
		  }




}
